/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PlayingField.java
 *
 * Created on 20.04.2011, 09:31:11
 */

package gui;

import java.util.Timer;
import logic.DiceController;

/**
 *
 * @author 76167
 */
public class PlayingField extends javax.swing.JFrame {

    /** Creates new form PlayingField */
    public PlayingField() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */

        public class DiceThread extends Thread{
            public void run() {
                try{
                    for(int i=0;i<=85;i++){
                        sleep(15);
                        diceArea1.getDice1().getjLabel1().setText(DiceController.throwDice());
                        diceArea1.getDice2().getjLabel1().setText(DiceController.throwDice());
                        diceArea1.getDice3().getjLabel1().setText(DiceController.throwDice());
                        diceArea1.getDice4().getjLabel1().setText(DiceController.throwDice());
                        diceArea1.getDice5().getjLabel1().setText(DiceController.throwDice());
                    }
                }catch(Exception e){}


                
            }
        }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        btnThrow = new javax.swing.JButton();
        diceArea1 = new gui.DiceArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        btnThrow.setText("Würfeln");
        btnThrow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnThrowActionPerformed(evt);
            }
        });

        diceArea1.setBorder(javax.swing.BorderFactory.createTitledBorder("Würfel"));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(diceArea1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(381, Short.MAX_VALUE)
                .addComponent(btnThrow, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(566, Short.MAX_VALUE)
                .addComponent(diceArea1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btnThrow)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnThrowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnThrowActionPerformed

        DiceThread dt = new DiceThread();
        dt.start();
    }//GEN-LAST:event_btnThrowActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PlayingField().setVisible(true);
            }
        });
    }

    public DiceArea getDiceArea1() {
        return diceArea1;
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnThrow;
    private gui.DiceArea diceArea1;
    // End of variables declaration//GEN-END:variables

}
